<%@ page language="java" import="java.util.*" pageEncoding="UTF-8"%>
<html>
<head>
<title>jsonp</title>
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery-1.11.1.min.js"></script>
<script>
// 请求是：http://localhost:8080/cas-client1/sxxx/kitty?callback=jQuery111109554336410958633_1513152885699&_=1513152885701
// 返回是：jQuery111109554336410958633_1513152885699([{"age": "22","birthday": "2017-01-08","id": "1","name": "D"},{"age": "21","birthday": "2012-01-08","id": "2","name": "C"}])

$(document).ready(function () {
	$("#btn").click(function () {
    	$.ajax({
			url: "http://localhost:8080/cas-client1/sxxx/kitty",
			type: "POST",   //post请求方式,其实还是get请求
			dataType: "jsonp",
			jsonp: "callback", // 默认也是callback
			success: function (data) {
				var result = JSON.stringify(data);
				$("#text").val(result);
			}
		});
	});
});
</script>
</head>
<body>
	<input id="btn" type="button" value="跨域获取数据" />
	<textarea id="text" style="width: 400px; height: 100px;"></textarea>
</body>
</html>
